package com.zhentao.kafka;

import com.alibaba.fastjson.JSON;
import com.zhentao.mapper.MaAnnouncementsMapper;
import com.zhentao.model.common.manger.pojo.Announcements;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 王越潇
 * @version 1.0
 * @Date 2024/10/9 8:52
 * @Type
 */
@Component
public class AnnouncementsKafka {
    @Resource
    private MaAnnouncementsMapper maAnnouncementsMapper;
    @KafkaListener(topics = "announcements")
    public void listen(String message) {
        System.out.println("接收到消息：" + message);
        Announcements announcements = JSON.parseObject(message, Announcements.class);
        announcements.setStatus(1);
        maAnnouncementsMapper.updateById(announcements);
    }
}
